<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script>
        var str = "诶必塞第衣爱抚即";
        var str1 = str.substr(2, 2);
        var str2 = str.substring(2, 4);
//        alert(str1 + " == " + str2);





        String.prototype.strLen = function() {
            var len = 0;
            for (var i = 0; i < this.length; i++) {
                if (this.charCodeAt(i) > 255 || this.charCodeAt(i) < 0) len += 2; else len ++;
            }
            return len;
        }
        //将字符串拆成字符，并存到数组中
        String.prototype.strToChars = function(){
            var chars = new Array();
            for (var i = 0; i < this.length; i++){
                chars[i] = [this.substr(i, 1), this.isCHS(i)];
            }
            String.prototype.charsArray = chars;
            return chars;
        }
        //判断某个字符是否是汉字
        String.prototype.isCHS = function(i){
            if (this.charCodeAt(i) > 255 || this.charCodeAt(i) < 0)
                return true;
            else
                return false;
        }
        //截取字符串（从start字节到end字节）
        String.prototype.subCHString = function(start, end){
            var len = 0;
            var str = "";
            this.strToChars();
            for (var i = 0; i < this.length; i++) {
                if(this.charsArray[i][1])
                    len += 2;
                else
                    len++;
                if (end < len)
                    return str;
                else if (start < len)
                    str += this.charsArray[i][0];
            }
            return str;
        }
        //截取字符串（从start字节截取length个字节）
        String.prototype.subCHStr = function(start, length){
            return this.subCHString(start, start + length);
        }
        var li= '总部基地，以前瞻性开发理念，为 企业提供高效、多能、全方位的经 营氛围和高速发展通.';

        for(var i=0;i<li.length;i++)
        {
            li[i].innerHTML=li[i].innerHTML.substr(0,28)+"...";
        }

        alert(li);
    </script>
</head>
<body>

</body>
</html>